//
//  TopListViewController.m
//  iMine
//
//  Created by gaoxiang on 09-3-30.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "GameLevelTopInfo.h"
#import "TopListView.h"
#import "ScoreClient.h"
#import "TopListViewController.h"

@implementation TopListViewController

- (id)initWithLevelKey:(NSString *)key
{
	if (![super init])
		return nil;
	
	levelKey = key;
	return self;
}

- (NSString *)nibName
{
	return @"TopListView";
}

-(void)awakeFromNib
{	
	NSRect viewFrame = NSMakeRect(4, 4, 425, 296);
	[[self view] setFrame:viewFrame];
}

- (void)setLevelKey:(NSString *)key
{
	levelKey = key;
}
- (NSString *)levelKey
{
	return levelKey;
}

- (void)refresh
{
	NSDictionary *data = [ScoreClient gameLevelData];
	if (!data) return;
	GameLevelTopInfo *glti = (GameLevelTopInfo *)[data objectForKey:levelKey];
	if (!glti) return;
	[(TopListView *)[self view] setScoreInfos:[glti scoreInfos]];
}
@end
